<div class="wrapper">
    <h1>分类列表：</h1>
    <a href="/index.php?c=admin&m=showThread" class="a_btn">全部</a>&nbsp;&nbsp;&nbsp;&nbsp;
    <?php foreach($category as $k=>$v):?>
    <a href="/index.php?c=admin&m=showThread&cid=<?php echo $k;?>" class="a_btn"><?php echo $v;?></a>&nbsp;&nbsp;&nbsp;&nbsp;
    <?php endforeach;?>
    <h1>文章列表：</h1>
    <table cellpadding="0" cellspacing="0" border="0" width="900">
        <thead>
            <tr>
                <th width="48%">标题</th>
                <th width="8%">分类</th>
                <th width="8%">浏览次数</th>
                <th width="16%">时间</th>
                <th width="20%">操作</th>
            </tr>            
        </thead>
        <tbody>
            <?php if(!empty($thread)):?>
            <?php foreach($thread as $key=>$value):?>
            <tr>
                <td><a href="/index.php?c=detail&id=<?php echo $value['tid'];?>" target="_blank"><?php echo $value['title'];?></a></td>
                <td><?php echo $category[$value['cid']];?></td>
                <td><?php echo $value['click'];?></td>
                <td><?php echo date("Y-m-d H:i:s",$value['datetime']);?></td>
                <td tid="<?php echo $value['tid'];?>"><a href="/index.php?c=admin&m=editThread&tid=<?php echo $value['tid'];?>" class="a_btn update_thread">编辑</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:void(0)" class="a_btn del_thread">删除</a></td>
            </tr>
            <?php endforeach;?>
            <?php else:?>
            <tr>
                <td colspan="6">暂无文章</td>
            </tr>
            <?php endif;?>
        </tbody>
    </table>
    <?php if(!empty($thread)):?>
    <ul>
        <li>
            <a>第<?php echo $page['current'];?>页</a>&nbsp;/&nbsp;<a>共<?php echo $page['count'];?>页</a>&nbsp;&nbsp;&nbsp;&nbsp;
            <a href="/index.php?c=admin&m=showThread&cid=<?php echo $cid;?>">首页</a>&nbsp;&nbsp;
            <a href="/index.php?c=admin&m=showThread&page=<?php echo $page['prev'];?>&cid=<?php echo $cid;?>">上一页</a>&nbsp;&nbsp;
            <a href="/index.php?c=admin&m=showThread&page=<?php echo $page['next'];?>&cid=<?php echo $cid;?>">下一页</a>&nbsp;&nbsp;
            <a href="/index.php?c=admin&m=showThread&page=<?php echo $page['count'];?>&cid=<?php echo $cid;?>">尾页</a>
        </li>
    </ul>
    <?php endif;?>
</div>
<script type="text/javascript">
    $(".del_thread").click(function(){
        var a = confirm("确认删除？");
        if(a) {
            var tid = $(this).parents("td").attr("tid");
            var url = "/index.php?c=admin&m=delThread";
            var data = {tid:tid};
            var res = _ajax(url, data);
            alert(res.info);
            window.location.reload();
            return true;
        }
        return false;
    });
    
</script>

